package nl.utwente.fmt.vertalerbouw.tarrh.encoder;

/**
 * Class to hold all data related to function entries in the encoder.
 */
public class EncoderFunctionEntry {
	private final String functionName;
	private final StringBuffer parameters = new StringBuffer();
	private final EncoderClassEntry returnType;
	private final boolean isMemberFunction;

	/**
	 * Returns true if the function represented by this entry is a member
	 * function.
	 * 
	 * @return true if this function is a member variable, false otherwise.
	 */
	public boolean isMemberFunction() {
		return isMemberFunction;
	}

	/**
	 * Construct a new function entry with the specified return type and
	 * function name.
	 * 
	 * @param returnType
	 *            the return type of the function.
	 * @param functionName
	 *            the function name.
	 */
	public EncoderFunctionEntry(EncoderClassEntry returnType, String functionName, boolean isMemberFunction) {
		super();
		this.returnType = returnType;
		this.functionName = functionName;
		this.isMemberFunction = isMemberFunction;
	}

	/**
	 * Add an additional parameter to the function represented by this entry.
	 * 
	 * @param type
	 *            the signature of the type of the new parameter.
	 */
	public void addParameterSignature(String type) {
		parameters.append(type);
	}

	/**
	 * Get the function name of the function represented by this entry.
	 * 
	 * @return the function name of this function.
	 */
	public String getFunctionName() {
		return functionName;
	}

	/**
	 * Get the signature of the parameters of the function represented by this
	 * entry.
	 * 
	 * @return the signature of the parameters of this function.
	 */
	public String getParameterSignature() {
		return parameters.toString();
	}

	/**
	 * Get the return type of function represented by this entry.
	 * 
	 * @return the return type.
	 */
	public EncoderClassEntry getReturnType() {
		return returnType;
	}
}
